<%@ page import="common.*,command.*,java.sql.*,db.*,java.util.*,org.apache.log4j.Logger" %><%

response.reset();
response.setContentType("text/xml;charset=utf-8");

Logger logger  = Logger.getLogger("ajax_cd_selectbox");
String Query_name = "ajax_common_code.query";
String temp = request.getParameter("s_key");
String[] param = null;

if (temp.indexOf("|") > 0){
	Query_name = "ajax_common_code2.query";
	param = new String[2];
	param[0]=temp.substring(0,temp.indexOf("|"));
	param[1]=temp.substring(temp.indexOf("|")+1,temp.length());
	System.out.println(":"+param[0]+":");
	System.out.println(":"+param[1]+":");
}else{
	param = new String[1];
	param[0]=temp;
	System.out.println(":"+param[0]+":");
}
Connection con = null;



StringBuffer sb = new StringBuffer(1024);

sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<content><![CDATA[");

try {
	con = (new CommonConnect()).getConnection_ds1();
//	String queryStr = QueryManager.getQuery("pmp001t.query");
	String queryStr =  QueryManager.getQuery(Query_name);
	DAO userdao = new DAO();
	System.out.println(queryStr);
    ArrayList list = userdao.select(con,queryStr,param);

		for (int i = 0; i < list.size(); i++) {
		    HashMap map = (HashMap)list.get(i);
		    logger.debug((String)map.get("cd")+"||"+(String)map.get("cd_nm"));
		    sb.append((String)map.get("cd"));
				sb.append("||");
		    sb.append((String)map.get("cd_nm"));		    
				sb.append("$$");
		}
  
} catch (Exception e) {
		e.printStackTrace();

}finally {
		  try{
			  if (con!=null) con.close();
		  }catch(Exception ee){}
	  }

sb.append("]]></content>");
out.println(sb.toString());

%>
